<%@page import="java.io.*"%>
<%

 String path= (String)request.getParameter("path");
 String filename= (String)request.getParameter("filename");
 System.out.println("path" + path);
 System.out.println("filename" + filename);

%>

<!--
<html>
<head>
<title>Document</title>
</head>
<style type="text/css">
	.small{font-size: 5pt; font:bold 80% Arial; color: #666666}
</style>
-->



<%
boolean supported = true;
File file = new File(path.trim()+"/" +filename.trim());
if(filename.indexOf(".gif") >-1)
	response.setContentType("image/gif");
else if(filename.indexOf(".jpg") >-1)
	response.setContentType("image/jpeg");
else if(filename.indexOf(".doc")>-1)
	response.setContentType("application/msword");
else if(filename.indexOf(".xls")>-1)
	response.setContentType("application/vnd.ms-excel");
else if(filename.indexOf(".pdf")>-1)
	response.setContentType("application/pdf");
else if(filename.indexOf(".txt")>-1)
	response.setContentType("text/plain");
else if(filename.indexOf(".htm")>-1)
	response.setContentType("text/html");
else if(filename.indexOf(".ppt") >-1)
	response.setContentType("application/vnd.ms-powerpoint");
else 
	response.setContentType("application");

response.setHeader("Content-disposition","attachment; filename=" + filename );

BufferedInputStream reader = new BufferedInputStream(new FileInputStream(file));
OutputStream writer = response.getOutputStream();
byte[] arrBytes = new byte[(int)file.length()];
reader.read(arrBytes);
writer.write(arrBytes);
writer.flush();
writer.close();
reader.close();
%>

<!--
<script>window.close()</script>
</html>
-->
